package org.uim.cricket.db.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import org.uim.cricket.db.DBThread;

public class DBDataSetResultQuery {

	public String[][] result(String theQuery, int noOfColumns) throws SQLException {
		DBThread dbt = new DBThread(theQuery);
		dbt.run();
		
		ResultSet rs = dbt.getResultSet();
		ArrayList<String[]> mdata = new ArrayList<String[]>();
		while (rs.next()) {
			String[] cols = new String[noOfColumns];
			for (int i=1; i<=noOfColumns; i++) {
				cols[i-1] = rs.getString(i);
			}
			mdata.add(cols);
		}
		dbt.close();
		
		String[][] data = new String[mdata.size()][];
		for (int i=0; i<mdata.size(); i++) {
			data[i] = mdata.get(i);
		}
		return data;
		
	}
	
}
